package test1230am;

public class Test19 {
    public static void m19(int[] arr) {
        int a = 0;
        int b = 0;
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] == 1) {
                a = i;
            }
            if (arr[i] == 5) {
                b = i;
            }
        }
        int c = arr[a];
        arr[a] = arr[b];
        arr[b] = c;
        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i]);
        }
    }
    public static void main(String[] args) {
        // (19)元素3和元素2互换位置
        int[] arr = {5, 3, 7, 2, 6};
        m19(arr);
    }
}
